# SPDX-FileCopyrightText: 2021 The Manyverse Authors
#
# SPDX-License-Identifier: Unlicense

platform :ios, '11.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'

target 'Manyverse' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  # FIXME: Can we delete this? See https://github.com/wix/react-native-navigation/blob/master/CHANGELOG.md#remove-rnn-pod-from-podspec
  # pod 'ReactNativeNavigation', :podspec => '../node_modules/react-native-navigation/ReactNativeNavigation.podspec'

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
  pod 'RNOS', :podspec => '../node_modules/react-native-os-staltz/RNOS.podspec'

  target 'ManyverseTests' do
    inherit! :complete
    # Pods for testing
  end

  use_frameworks!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next lines.
  # use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)

    # Hack copied from https://github.com/facebook/react-native/issues/31034#issuecomment-812564390
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end

      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
  end

end
